package com.damon.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 * 查询当前用户的任务列表
 * @Date 2020/4/7 17:26
 * @Created by Damon
 */
public class ActivitiTaskQuery {

    public static void main(String[] args) {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        TaskService taskService = processEngine.getTaskService();

        /*List<Task> taskList = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee("lisi")
                .list();
        for (Task task :taskList) {
            System.out.println(task.getProcessInstanceId());// act_hi_taskinst
            System.out.println(task.getId());// act_ru_task
            System.out.println(task.getAssignee());// act_hi_taskinst
            System.out.println(task.getName());// act_ru_task
        }*/
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee("ww")
                .singleResult();
        System.out.println(task.getProcessInstanceId());// act_hi_taskinst
        System.out.println(task.getId());// act_ru_task
        System.out.println(task.getAssignee());// act_hi_taskinst
        System.out.println(task.getName());// act_ru_task
    }
}
